package se.webbzon.oschi01.utils;

import java.util.Map.Entry;

public class Pair<L,R> implements Entry<L,R>, Cloneable {
	
	protected L left;
	
	protected R right;
	
	public Pair() {}
	
	public Pair(L left, R right) {
		this.left = left;
		this.right = right;
	}
	
	public Pair(Pair<L,R> other) {
		this.left = other.left;
		this.right = other.right;
	}
	
	public L getLeft() {
		return left;
	}

	public void setLeft(L left) {
		this.left = left;
	}

	public R getRight() {
		return right;
	}

	public void setRight(R right) {
		this.right = right;
	}

	@Override public Pair<L,R> clone() {
		return new Pair<L,R>(this);
	}

	@Override public L getKey() {
		return getLeft();
	}

	@Override public R getValue() {
		return getRight();
	}

	@Override public R setValue(R value) {
		R right = getRight();
		setRight(value);
		return right;
	}
	
	@Override public String toString() {
		return left + "=" + right;
	}

}
